<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>发货订单</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="admin.css" rel="stylesheet" type="text/css" />
<link href="cxcalendar.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../script/jquery-1.4.4.min.js"></script>
<script language="javascript" src="../script/Calendar-new.js"></script>
<script type="text/javascript">
function import_express(){
    window.parent.iframe_form("importexpress", '上传导入文件', '<{$config.weburl}>/admin/module.php?m=product&s=emssc_express_paper_print.php&act=importexpress', 300,300);
    return false;
}
</script>
</head>
<body>
<div class="container">
    <div class="flow">
        <div class="itemtitle">
            <h3>四川邮政小包订单</h3>
            <ul>
                <li class="current"><a href="?m=<{$smarty.get.m}>&s=<{$smarty.get.s}>"><span>管理</span></a></li>
            </ul>
            <ul style="float:right;">
                <li>
                    <form method="post" target="export_iframe_1" id="export_form_1" action=""><input type="hidden" value="export_oid_eid" name="act"/></form>
                    <iframe src="" style="display:none;" id="export_iframe_1" name="export_iframe_1"></iframe>
                    <a href="javascript:;" onclick="$('#export_form_1').submit();"><span>导出订单号/运单号</span></a>
                </li>
                <li>
                    <form method="post" target="export_iframe" id="export_form" action=""><input type="hidden" value="export" name="act"/></form>
                    <iframe src="" style="display:none;" id="export_iframe" name="export_iframe"></iframe>
                    <a href="javascript:;" onclick="$('#export_form').submit();"><span>导出EXCEL</span></a>
                </li>
                <{if 0}><li><a href="javascript:;" onclick="import_express();"><span>导入运单号</span></a></li>
                <li>
                    <form method="post" target="export_customs_iframe" id="export_customs_form" action=""><input type="hidden" value="export_customs" name="act"/></form>
                    <iframe src="" style="display:none;" id="export_customs_iframe" name="export_customs_iframe"></iframe>
                    <a href="javascript:;" onclick="$('#export_customs_form').submit();"><span>导出海关申报数据</span></a>
                </li><{/if}>
            </ul>
        </div>
    </div>
    <div class="h35"></div>
    <form action="" method="get">
    <input type="hidden" name="m" value="<{$smarty.get.m}>">
    <input type="hidden" name="s" value="emssc_express_paper_print.php">
    <table class="select_table">
        <tr>    
            <td>
                <div class="select_box">
                    <select name="stock_shop" id="stock_shop" style="float:left;">
	                <option value="" <{if $general_shop!=0}>disabled<{/if}>>全部</option>
	                <{foreach item=list from=$stock_shops}>
	                <option value="<{$list.id}>" <{if $smarty.get.stock_shop==$list.id}>selected<{/if}> <{if $general_shop!=0&&$general_shop!=$list.id}>disabled<{/if}>><{$list.title}></option>
	                
	                <{/foreach}>
	                </select>
	                <input placeholder="请输入订单编号..." type="text" name="code" class="w180" value="<{$smarty.get.code}>"  />
	            </div>
           </td>
           <td>
                    <span>&nbsp;打印状态:</span>
                    <span><select name="express_print_status"><option value="" <{if !$smarty.get.express_print_status and $smarty.get.express_print_status!='0'}>selected<{/if}> >不限</option><option value="0" <{if $smarty.get.express_print_status=='0'}>selected<{/if}> >未打印</option><option value="1" <{if $smarty.get.express_print_status and $smarty.get.express_print_status=='1'}>selected<{/if}> >已打印</option></select></span>
                    <span>&nbsp;导出状态:</span>
                    <span><select name="express_export_status"><option value="" <{if !$smarty.get.express_export_status and $smarty.get.express_export_status!='0'}>selected<{/if}> >不限</option><option value="0" <{if $smarty.get.express_export_status=='0'}>selected<{/if}> >未导出</option><option value="1" <{if $smarty.get.express_export_status and $smarty.get.express_export_status=='1'}>selected<{/if}> >已导出</option></select></span>
                    <span>&nbsp;订单状态:</span>
                    <span><select name="status"><option value="">不限</option><option value="2" <{if $smarty.get.status=='2'}>selected<{/if}> >未发货</option><option value="3" <{if $smarty.get.status=='3'}>selected<{/if}> >已发货</option><option value="4" <{if $smarty.get.status=='4'}>selected<{/if}> >已完成</option></select></span>
                    <span>&nbsp;发货时间：</span>
                    <span>
                            <input class="w120 input_cxcalendar" type="text" name="s_stime" id="s_stime" value="<{$smarty.get.s_stime}>">
                            -
                            <input class="w120 input_cxcalendar" type="text" name="s_etime" id="s_etime" value="<{$smarty.get.s_etime}>">
                    </span>
                    <span>&nbsp;打单时间：</span>
                    <span>
                            <input class="w120 input_cxcalendar" type="text" name="p_stime" id="p_stime" value="<{$smarty.get.p_stime}>">
                            -
                            <input class="w120 input_cxcalendar" type="text" name="p_etime" id="p_etime" value="<{$smarty.get.p_etime}>">
                    </span>
           </td>
        </tr>
        <tr>
        	<td>
           		<span>&nbsp;运单号:</span>
           		<span><textarea name="shipping_no" style="resize:horizontal;height:30px;" placeholder="多个请用英文逗号隔开"><{$smarty.get.shipping_no}></textarea></span>
            </td>
            <td>
                <input type="submit" value="搜索" />
            </td>
        </tr>
    </table>
    </form>
    <table class="table product">
       <tbody>
       <tr class="header">
            <th width="30">查看</th>
            <th width="60">操作</th>
            <th width="60">打印</th>
            <th width="60">打印状态</th>
            <th width="100">订单编号</th>
            <th width="60">导出状态</th>
            <th width="60">订单状态</th>
            <th width="60">重量</th>
            <th width="60">运费</th>
            <th width="60">行邮税</th>
            <th width="100">快递类型</th>
            <th width="100">快递单号</th>
            <th width="100">下单时间</th>
            <th width="100">发货时间</th>
            <th width="100">打单时间</th>
        </tr>
        <{foreach item=list from=$de.list}>
        <tr>
            <td><a href="?m=product&s=order_detail.php&oid=<{$list.order_id}>"><{$lookimg}></a></td>
            <td><{if $list.status==3}>已发货<{else}><a class="a-opear" data-type="ship" data-param="{'id':'<{$list.order_id}>'}" href="javascript:void(0)">发货</a><{/if}></td>
            <td><{if $list.shipping_no }><a class="a-opear" data-type="expressprint" data-param="{'id':'<{$list.order_id}>','express_print_status':'<{$list.express_print_status}>'}" href="javascript:void(0)">运单</a><{else}><span stype="color:gray;">运单</span><{/if}></td>
            <td><{if $list.express_print_status==1}><span style="color:red;">已打印</span><{else}><span style="color:green;">未打印</span><{/if}></td>
            <td><{$list.order_id}><{if $list.order_type==2}><b>(分销订单)</b><{/if}><{if $list.order_type==3}><b>(微店订单)</b><{/if}></td>
            <td><{if $list.express_export_status==1}>已导出<{else}>未导出<{/if}></td>
            <td><{if $list.status==3}>已发货<{elseif $list.status==4}>已完成<{else}>未发货<{/if}></td>
            <td><{if $list.shipping_weight }><{$list.shipping_weight }>KG<{/if}></td>
            <td><{$config.money}><{$list.shipping_freight_rmb}></td>
            <td><{$config.money}><{$list.tax_price}></td>
            <td><{$list.shipping_express_name}></td>
            <td><{$list.shipping_no}></td>
            <td><{$list.order_time|date_format:"%Y-%m-%d&nbsp;%H:%M:%S"}></td>
            <td><{$list.ship_time|date_format:"%Y-%m-%d&nbsp;%H:%M:%S"}></td>
            <td><{$list.express_print_time|date_format:"%Y-%m-%d&nbsp;%H:%M:%S"}></td>
        </tr>
        <{foreachelse}>
        <tr>
            <td class="norecord" colspan="99"><i></i><span>暂无符合条件的数据记录</span></td>
        </tr>
        <{/foreach}>
        </tbody>
        <tfoot>
            <tr>
                <td colspan="99">
                    <div class="fl">每页最多显示： 20条</div>
                    <div class="page"><{$de.page}></div>
                    <div class="fr">共有<{$de.count}>条记录</div>
                </td>
            </tr>
        </tfoot>
    </table>
<script>
$(".a-opear").live('click',function(){
    
    var data = $(this).attr('data-param');
    eval("data = "+data);
    var type = $(this).attr('data-type');
    if(!data.id)
    {
        error('error','对不起，请选择订单后操作！');
        return false;
    }
   if(type=='expressprint'){
       var flag = false;
       var express_print_status = false;
       if(data.express_print_status=='1'){
           flag = confirm('已经打印过该订单，确认打印？');
           express_print_status = true;
       }
       if(express_print_status && !flag){
           return false;
       }
        //window.parent.iframe_form("expressprint", '快递单打印', '<{$config.weburl}>/admin/module.php?m=logistics&s=print.php&type=expressprint&oid='+data.id, 850,500);
        printArea(data.id);
    
        return false;
    }
    window.parent.ajax_form("order", "操作订单", '<{$config.weburl}>/admin/module.php?m=product&s=order_opear.php&type='+type+'&orderid='+data.id, 800);
    return false;
    
});
$('.operate').hover(function(){                  
    if ($(this).position().top + $(this).children("ul").height() + $(this).parent("td").height() - $(window).height()- $(window).scrollTop()  < 0) {
        $(this).addClass("hover");
        $(this).children("ul").css("top", "22px");
    } else {
        $(this).addClass("hover-up");
        $(this).children("ul").css("top", -$(this).children("ul").height());
    }
},function(){
    $(this).removeClass("hover").removeClass("hover-up");   
});

//时间搜索
$('.input_cxcalendar').each(function(){
    var a = new Calendar({
        targetCls: $(this),
        type: 'yyyy-mm-dd HH:MM:SS',
        wday:2
    },function(val){
        console.log(val);
    });
});

function printArea(id){
	 var iframe = document.createElement('IFRAME');
     iframe.src='<{$config.weburl}>/admin/module.php?m=logistics&s=print.php&type=expressprint&oid='+id;
     iframe.width='0'
     iframe.height='0'
     document.body.appendChild(iframe);
     var frameWindow = iframe.contentWindow;
     frameWindow.onload=function(){
    	 
    	 frameWindow.document.getElementById("print_btn").style.display="none";
    	 frameWindow.close();
         frameWindow.focus();
         frameWindow.print();

         window.parent.message_confirm("confirm_print", "打印完成", "打印完成？", function(){
            document.body.removeChild(iframe);
             //更新打印状态
             $.get('<{$config.weburl}>/admin/module.php?m=logistics&s=print.php&type=update_express_print_status&oid='+id,function(data){
                 window.parent.main.document.location.reload();
             });
         }, function(){

            document.body.removeChild(iframe);
             printArea(id);
         },300)
     }     
}
</script>    
</div>
</body>
</html>